summaryrefslogtreecommitdiff
path: root/verilog/immediate.v
diff options
context:
space:
mode:
authorJoshua Yun <jjyun4@illinois.edu>2023-08-28 14:42:23 -0500
committerJoshua Yun <jjyun4@illinois.edu>2023-08-28 14:42:23 -0500
commitc1fa3c36da28e9e947f6279329c47777f31fe7a2 (patch)
treebd321c8e33200427b23bffe96c7c1bae90d8a044 /verilog/immediate.v
parentd069ea63cce08c0f5c8d7da7f8ab05115bd8d856 (diff)
downloadriscv-processor-inorder-master.tar.gz
Added new riscv processor design into git repoHEADmaster
Diffstat (limited to 'verilog/immediate.v')
-rw-r--r--verilog/immediate.v20
1 files changed, 20 insertions, 0 deletions
diff --git a/verilog/immediate.v b/verilog/immediate.v
new file mode 100644
index 0000000..37111da
--- /dev/null
+++ b/verilog/immediate.v
@@ -0,0 +1,20 @@
+`default_nettype none
+`timescale 1ns/1ps
+
+module immediate
+(
+ input wire [31:7] instr,
+ input wire i,u,j,b,
+ output wire [31:0] imm
+);
+
+// Note, can get rid of S signal if needed
+assign imm[31] = instr[31];
+assign imm[30:20] = u ? instr[30:20] : {11{instr[31]}};
+assign imm[19:12] = (u|j) ? instr[19:12] : {8{instr[31]}};
+assign imm[11] = ~u & (b ? instr[7] : (j ? instr[20] : instr[31]));
+assign imm[10:5] = {6{~u}} & instr[30:25];
+assign imm[4:1] = {4{~u}} & (i|j ? instr[24:21] : instr[11:8]);
+assign imm[0] = ~(u|j|b) & (i ? instr[20] : instr[7]);
+
+endmodule