hp-saturn/saturn_top.v

83 lines
1.6 KiB
Coq
Raw Normal View History

2019-02-24 23:30:57 +01:00
/*
(c) Raphaël Jacquot 2019
This file is part of hp_saturn.
hp_saturn is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
hp_saturn is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
`default_nettype none
2019-02-24 23:30:57 +01:00
`ifdef SIM
module saturn_top;
`else
module saturn_top (
clk_25mhz,
btn,
led
);
input wire [0:0] clk_25mhz;
input wire [6:0] btn;
2019-03-03 13:33:32 +01:00
`endif
`ifdef SIM
2019-03-03 13:33:32 +01:00
wire [7:0] led;
`else
output wire [7:0] led;
wire [0:0] reset;
wire [0:0] halt;
assign reset = btn[0];
`endif
2019-02-24 23:30:57 +01:00
saturn_bus main_bus (
`ifdef SIM
2019-02-24 23:30:57 +01:00
.i_clk (clk),
`else
.i_clk (clk_25mhz),
`endif
2019-02-24 23:30:57 +01:00
.i_reset (reset),
2019-03-03 13:33:32 +01:00
.o_halt (halt),
.o_char_to_send (led)
2019-02-24 23:30:57 +01:00
);
`ifdef SIM
2019-02-24 23:30:57 +01:00
reg [0:0] clk;
reg [0:0] reset;
wire [0:0] halt;
initial begin
2019-03-02 15:01:00 +01:00
$display("TOP : starting the simulation");
2019-03-02 13:22:09 +01:00
clk = 0;
reset = 1;
2019-02-24 23:30:57 +01:00
@(posedge clk);
@(posedge clk);
@(posedge clk);
2019-03-02 13:22:09 +01:00
reset = 0;
2019-03-02 15:01:00 +01:00
$display("TOP : reset done, waiting for instructions");
2019-02-24 23:30:57 +01:00
@(posedge halt);
2019-03-02 15:01:00 +01:00
$display("TOP : instructed to stop, halt is %b", halt);
2019-02-24 23:30:57 +01:00
$finish;
end
2019-03-02 13:22:09 +01:00
always
#10 clk = (clk === 1'b0);
`endif
2019-03-02 13:22:09 +01:00
2019-02-24 23:30:57 +01:00
endmodule