-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathopdecoder.v
More file actions
80 lines (66 loc) · 1.2 KB
/
opdecoder.v
File metadata and controls
80 lines (66 loc) · 1.2 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
`timescale 1ns / 1ps
/*
module OpDecoder(clk, );
// we: Write Enable
input clk, we;
input [15:0]addr;
input [31:0]wdata;
output [31:0]data;
reg [3:0] state;
assign data = rom[addr];
always @ (posedge clk)
begin
if(we == 1) begin
rom[addr] = wdata;
end
end
initial
begin
$readmemh("rom.hex", rom);
end
endmodule
*/
`timescale 1ns / 1ps
// timescale [単位時間] / [丸め精度]
/*
module testbench();
reg clk;
// regは値を保持してくれる。
// wireは値を保持してくれない。
reg [15:0] counter;
reg [31:0] wdata;
reg we;
reg PCinc;
wire [31:0] data;
memory mem(clk, counter, data, wdata, we);
initial
begin
// 初期化ブロック。
// 出力する波形ファイルをここで指定する。
$dumpfile("memory.vcd");
$dumpvars(0, testbench);
PCinc = 0;
#1;
counter = 0;
#3;
PCinc = 1;
end
always // 常に実行される。
begin
// クロックを生成する。
// #1; は、1クロック待機する。
clk <= 1; #1;
clk <= 0; #1;
end
always @ (posedge clk)
begin
if(PCinc == 1) begin
counter = counter + 1;
end
if(counter === 1000) begin
$display ("Simulation end");
$finish;
end
end
endmodule
*/