diff options
| author | Julian Blake Kongslie | 2021-07-06 09:44:36 -0700 |
|---|---|---|
| committer | Julian Blake Kongslie | 2021-07-06 09:44:36 -0700 |
| commit | 60e1775b874015a3451e4bde10a8eb30701b1165 (patch) | |
| tree | 477a2835c0f7e616bdeeabe6aee85f8af8b79650 /sim/pc.sv | |
| download | breadboarding-60e1775b874015a3451e4bde10a8eb30701b1165.tar.xz | |
Initial commit.
Diffstat (limited to 'sim/pc.sv')
| -rw-r--r-- | sim/pc.sv | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/sim/pc.sv b/sim/pc.sv new file mode 100644 index 0000000..1a3aaee --- /dev/null +++ b/sim/pc.sv | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | module pc | ||
| 2 | #( parameter UROM = "<no file specified>" | ||
| 3 | , parameter UIP_BITS = 15 | ||
| 4 | , parameter UROM_BITS = 8 | ||
| 5 | , parameter BUS_BITS = 16 | ||
| 6 | , parameter RESET = 0 | ||
| 7 | ) | ||
| 8 | ( input bit clk | ||
| 9 | , input bit reset | ||
| 10 | , input bit [UIP_BITS-1:0] uip | ||
| 11 | , inout bit [BUS_BITS-1:0] abus | ||
| 12 | , inout bit [BUS_BITS-1:0] dbus | ||
| 13 | ); | ||
| 14 | |||
| 15 | bit [BUS_BITS-1:0] addr; | ||
| 16 | |||
| 17 | typedef enum | ||
| 18 | { LOAD | ||
| 19 | , INCREMENT | ||
| 20 | , OUTADDR | ||
| 21 | } CtrlBit; | ||
| 22 | |||
| 23 | bit [UROM_BITS-1:0] ctrl; | ||
| 24 | urom#(UROM, UIP_BITS, UROM_BITS) urom(uip, ctrl); | ||
| 25 | |||
| 26 | assign abus = ctrl[OUTADDR] ? addr : {(BUS_BITS){1'bZ}}; | ||
| 27 | |||
| 28 | always @(posedge clk) begin | ||
| 29 | if (reset) begin | ||
| 30 | addr <= RESET; | ||
| 31 | end else begin | ||
| 32 | addr <= (ctrl[LOAD] ? abus : addr) + (ctrl[INCREMENT] ? 1 : 0); | ||
| 33 | end | ||
| 34 | end | ||
| 35 | |||
| 36 | endmodule | ||
