diff options
| author | Julian Blake Kongslie | 2021-03-23 12:22:38 -0700 |
|---|---|---|
| committer | Julian Blake Kongslie | 2021-03-23 12:22:38 -0700 |
| commit | 5d95607192380be5cc62592efac52814a0e090df (patch) | |
| tree | 656bc3ec79180a89f355681e454808ebce6eb6d9 /fibseq.sv | |
| download | toycpu-5d95607192380be5cc62592efac52814a0e090df.tar.xz | |
Initial commit.
Diffstat (limited to 'fibseq.sv')
| -rw-r--r-- | fibseq.sv | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/fibseq.sv b/fibseq.sv new file mode 100644 index 0000000..f877b98 --- /dev/null +++ b/fibseq.sv | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | module fibseq | ||
| 2 | #( BITS = 8 | ||
| 3 | ) | ||
| 4 | ( input bit clk | ||
| 5 | , input bit reset | ||
| 6 | |||
| 7 | , input bit ready `define ready $past(ready) | ||
| 8 | , output bit valid | ||
| 9 | , output bit [BITS-1:0] data | ||
| 10 | ); | ||
| 11 | |||
| 12 | bit [BITS-1:0] a; | ||
| 13 | bit [BITS-1:0] b; | ||
| 14 | |||
| 15 | always_ff @(posedge clk) begin | ||
| 16 | if (reset) begin | ||
| 17 | valid = 0; | ||
| 18 | a = 0; | ||
| 19 | b = 1; | ||
| 20 | end else begin | ||
| 21 | if (`ready) valid = 0; | ||
| 22 | if (!valid) begin | ||
| 23 | valid = 1; | ||
| 24 | data = a; | ||
| 25 | {a, b} = {b, a + b}; | ||
| 26 | end | ||
| 27 | end | ||
| 28 | end | ||
| 29 | |||
| 30 | endmodule | ||
