forked from mit-plv/koika
-
Notifications
You must be signed in to change notification settings - Fork 0
/
top.v
67 lines (51 loc) · 1.73 KB
/
top.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// -*- verilog -*-
/*! Verilog wrapper for the Kôika core (for use in simulation) !*/
// This toplevel is mostly for simulation, since it assumes the UART module
// is always ready to transmit.
module top(input CLK, input RST_N, output uart_wr_valid, output[7:0] uart_wr_data, output LED);
wire[69:0] dmem_out;
wire[69:0] dmem_arg;
wire[69:0] imem_out;
wire[69:0] imem_arg;
wire uart_wr_ready = 1'b1;
wire uart_rd_valid = 1'b0;
wire[7:0] uart_rd_data = 8'b0;
wire led_wr_valid;
wire led_wr_data;
reg led = 1'b0;
assign LED = led;
rv32 core(.CLK(CLK), .RST_N(RST_N),
.ext_mem_dmem_arg(dmem_arg),
.ext_mem_dmem_out(dmem_out),
.ext_mem_imem_arg(imem_arg),
.ext_mem_imem_out(imem_out),
.ext_uart_write_arg({uart_wr_valid, uart_wr_data}),
.ext_uart_write_out(uart_wr_ready),
.ext_uart_read_arg(),
.ext_uart_read_out({uart_rd_valid, uart_rd_data}),
.ext_led_arg({led_wr_valid, led_wr_data}),
.ext_led_out(led));
ext_mem imem(.CLK(CLK), .RST_N(RST_N), .arg(imem_arg), .out(imem_out));
ext_mem dmem(.CLK(CLK), .RST_N(RST_N), .arg(dmem_arg), .out(dmem_out));
always @(posedge CLK)
if (led_wr_valid)
led <= led_wr_data;
`ifndef STDERR
`define STDERR 32'h80000002
`endif
`ifdef SIMULATION
always @(posedge CLK) begin
if (led_wr_valid) begin
if (led_wr_data)
$fwrite(`STDERR, "☀");
else
$fwrite(`STDERR, "🌣");
end
if (uart_wr_ready && uart_wr_valid)
$fwrite(`STDERR, "%c", uart_wr_data);
end
`endif
endmodule
// Local Variables:
// flycheck-verilator-include-path: ("../../_objects/rv32i.v/")
// End: