summaryrefslogtreecommitdiff
path: root/sim/control.sv
diff options
context:
space:
mode:
authorJulian Blake Kongslie2021-07-06 09:44:36 -0700
committerJulian Blake Kongslie2021-07-06 09:44:36 -0700
commit60e1775b874015a3451e4bde10a8eb30701b1165 (patch)
tree477a2835c0f7e616bdeeabe6aee85f8af8b79650 /sim/control.sv
downloadbreadboarding-60e1775b874015a3451e4bde10a8eb30701b1165.tar.xz
Initial commit.
Diffstat (limited to '')
-rw-r--r--sim/control.sv54
1 files changed, 54 insertions, 0 deletions
diff --git a/sim/control.sv b/sim/control.sv
new file mode 100644
index 0000000..7808f61
--- /dev/null
+++ b/sim/control.sv
@@ -0,0 +1,54 @@
1module control
2 #( parameter UROM = "<no file specified>"
3 , parameter UIP_BITS = 15
4 , parameter UROM_BITS = 8
5 , parameter BUS_BITS = 16
6 , parameter CONST_0 = "<no file specified>"
7 , parameter CONST_1 = "<no file specified>"
8 , parameter RESET = ~0
9 )
10 ( input bit clk
11 , input bit reset
12 , output bit [UIP_BITS-1:0] uip
13 , inout bit [BUS_BITS-1:0] abus
14 , inout bit [BUS_BITS-1:0] dbus
15 );
16
17typedef enum
18 { HALT
19 , SET_UIP_COND
20 , NOCOND
21 , OUTADDR
22 , OUTDATA
23 } CtrlBit;
24
25bit [UROM_BITS-1:0] ctrl;
26urom#(UROM, UIP_BITS, UROM_BITS) urom(uip, ctrl);
27
28bit [UROM_BITS*2-1:0] constant;
29urom#(CONST_0, UIP_BITS, UROM_BITS) const_0(uip, constant[1*UROM_BITS-1:0*UROM_BITS]);
30urom#(CONST_1, UIP_BITS, UROM_BITS) const_1(uip, constant[2*UROM_BITS-1:1*UROM_BITS]);
31
32assign abus = ctrl[OUTADDR] ? constant : {(BUS_BITS){1'bZ}};
33assign dbus = ctrl[OUTDATA] ? constant : {(BUS_BITS){1'bZ}};
34
35bit cond;
36assign cond = (dbus != 0) || ctrl[NOCOND];
37
38always @(posedge clk) begin
39 if (reset) begin
40 uip <= RESET;
41 end else begin
42 if (! ctrl[HALT]) begin
43 if (ctrl[SET_UIP_COND] && cond) begin
44 uip <= abus[UIP_BITS-1:0];
45 end else begin
46 uip <= uip + 1;
47 end
48 end else begin
49 $finish;
50 end
51 end
52end
53
54endmodule