MiniCPUとI2Cバスの接続
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[MenuBar]]
* 概要 [#zaba5b6a]
- miniCPU をI2Cのmaster device として、I2Cのslave device ...
- 動作モードを変更することにより、I2Cのslave device を手...
- 動作モードの変更は、5つのボタンの、左右(西と東)を使っ...
- miniCPUのクロックは、中央のボタンを押したり離したりして...
- miniCPUでI2Cの slave device を動かしているとき、miniCPU...
* 回路の概要 [#oe8fa2dd]
- miniCPU を構成する部品は、[[MiniCPU]]のものをそのまま使...
- 「[[I2Cデバイスを手で動かしてみる]]」の回路を拡張して、...
- sw[15:0]と up button, left button, center button, right...
- sclx が1のときは、sclはZ(high impedance), sclxが0のとき...
- sdax が1のときは、sdaはZ(high impedance), sclxが0のとき...
- 動作モードを表すレジスタ, operationMode を使います。ope...
-- 動作モードをカラーLED 1で表示します。
-- 動作モード 0 のときは、miniCPUのクロック(cpuCLK)や run...
-- 動作モード 1 のときは、BCxを miniCPUのクロックに接続し...
-- 動作モード 2 のときは, BCxを miniCPUのクロックに接続し...
- 動作モードの表 &br;
|operationMode |Color LED 1|cpuClk|cpuRun|cpuIn|sSegArray...
|0| {0,0,0} | 0 | 0 | 0| {16{0}, data,swx[7:0]}|{data,swx...
|1|{0,0,1}|BCx|BNx|swx|{{0},cpuCs,pcout,irout}|out|1,1|{0...
|2|{0,1,0}|BCx|BNx|{8{0},data}|{{0},cpuCs,abus,dbus}|{dat...
- down button をリセット信号とします。
- sda を led[8] に接続します。scl が 0->1 に変化するたび...
- 1つのポートで入出力を行う為、scl, sda は verilog の in...
* verilog [#l41887fa]
- [[MiniCPU]] の top.v と ram.v を以下の verilog で置き換...
- 以下の ram.v は、ADT7420 で計測された温度を取得し, led ...
- top.v
module top(sSegAnode, sSegCathode, sw, ledOut, colorLed_...
bu, bd, bl, br, bc, scl, sda,
bclck
);
output [7:0] sSegAnode;
output [7:0] sSegCathode;
output [15:0] ledOut; // led[8] ... if sd...
// else ...
// it i...
// led[0] correspond...
// led[1] corresponding to sw[1]
// led[2] corresponsing to center button, ...
output [2:0] colorLed_1;
output [2:0] colorLed_2; // color LED
input [15:0] sw; // sw[15:8] ... for ...
// sw[0] ... if 1...
// sw[1] ... if 1 sda is receiving(1), e...
// sw[2] ... sending sda.
input bu, bd, bl, br, bc, bclck; // bd corresponding...
// bc corresponding...
// if posedge bl is detected, sw is shown i...
inout scl, sda;
reg sclx, sdax;
assign scl=(~sclx)?1'b0:1'bz;
assign sda=(~sdax)?1'b0:1'bz;
wire BNx, BWx, BEx, BCx;
// reset: BSx
// BWx, BEx ... change operationMode
//
wire [15:0] swx;
wire reset;
// reg sclRw, sdaRw; // write=1, read=0;
reg cpuClk,cpuRun;
reg [7:0] data;
reg [1:0] operationMode;
// operationMode: 0 ... manual operation of peripherals
// 1 ... CPU independent
// 2 ... CPU, I2C connected
reg [15:0] ledWire,cpuIn;
wire [2:0] cpuCs;
wire [11:0] pcout,abus;
wire [15:0] irout,qtop,dbus,out;
reg [31:0] sSegArray;
reg [15:0] led;
assign ledOut=led;
reg [2:0] colorLed_1x, colorLed_2x;
//
assign colorLed_1=colorLed_1x;
// assign colorLed_2=colorLed_2x;
assign reset=~bd;
// always @(sclx or sdax ) begin
// colorLed_2x[0]<=sclx;
// colorLed_2x[1]<=sdax;
// colorLed_2x[2]<=0;
// end
assign colorLed_2={0,sda,scl};
always @(posedge sclx, negedge reset) begin
if(!reset) begin
data<=0;
end
else
data<={data[6:0],sda};
end
// for operation mode
always @(posedge BEx or negedge reset) begin
if(!reset) begin
operationMode<=0;
end
else
if(BEx) operationMode<=operationMode+1;
end
// always @(operationMode or swx[0] or BCx or data or B...
always @(operationMode) begin
case(operationMode)
0: begin
colorLed_1x=3'b000;
cpuClk=0; cpuRun=0; cpuIn=0;
sSegArray={{16{0}},data,swx[7:0]};
led[15:8]=data;
led[7:0]=swx[7:0];
sclx=BCx;
sdax=swx[0];
end
1: begin // CPU independent,
colorLed_1x=3'b001;
cpuClk=BCx; cpuRun=BNx; cpuIn=swx;
sSegArray={{0},cpuCs,pcout,irout};
led={{0{16}},out};
sclx=1'b1;
sdax=1'b1;
end
2: begin
colorLed_1x=3'b010;
cpuClk=BCx; cpuRun=BNx; cpuIn={{8{0}},data};
sSegArray={{0},cpuCs,abus,dbus};
led[15:8]=data;
led[7:0]=out[7:0];
sclx=out[1];
sdax=out[0];
end
default begin
colorLed_1x=3'b011;
cpuClk=BCx; cpuRun=BNx; cpuIn=swx;
sSegArray={{0{16}},data,swx[7:0]};
led[15:8]=data;
led[7:0]=swx[7:0];
sclx=BCx;
sdax=swx[0];
end
endcase
end
chattering #(20) chattering0(.clk(bclck), .reset(reset...
// assign BNx=bu;
// assign BWx=bl;
// assign BEx=br;
// assign BCx=bc;
// assign swx=sw;
sSegArray sSegArray0(.clk(bclck), .reset(reset), .load(...
minicpu minicpu0(.clk(cpuClk), .reset(reset), .run(cpu...
endmodule
- ram0
module ram(clk, load, addr, d, q
);
parameter DWIDTH=16, AWIDTH=12, WORDS=4096;
input clk, load;
input [AWIDTH-1:0] addr;
input [DWIDTH-1:0] d;
output [DWIDTH-1:0] q;
reg [DWIDTH-1:0] q;
reg [DWIDTH-1:0] mem [WORDS-1:0];
always @(posedge clk)
begin
if(load) mem[addr] <= d;
q <= mem[addr];
end
integer i;
initial begin
for(i=0; i<WORDS; i=i+1)
mem[i]=12'h000;
mem[8'h00] = 16'h1000; // PUSHI 0
mem[8'h01] = 16'h3011; // POP i ... i=0;
mem[8'h02] = 16'h2011; // L1 PUSH i
mem[8'h03] = 16'h1012; // PUSHI C
mem[8'h04] = 16'hF000; // ADD
mem[8'h05] = 16'h7000; // LD ... C[i];
mem[8'h06] = 16'hE000; // OUT ... print(C[i]) ;
mem[8'h07] = 16'h2011; // PUSH i;
mem[8'h08] = 16'h1001; // PUSH 1
mem[8'h09] = 16'hF000; // ADD
mem[8'h0A] = 16'h3011; // POP i
mem[8'h0B] = 16'h2011; // PUSH i
mem[8'h0C] = 16'h2010; // PUSH n
mem[8'h0D] = 16'hF001; // SUB
mem[8'h0E] = 16'h6002; // JNZ L1: if(i<n) goto L1;
mem[8'h0F] = 16'h0000; // L2: HALT
mem[8'h10] = 16'h0076; // n: 0x76 ... 0x88-0x12
mem[8'h11] = 16'h0000; // i:
//
// data for controlling i2c
// (MSB) ...... scl, sda (LSB)
mem[8'h12] = 16'h0003; // C: 11
mem[8'h13] = 16'h0002; // 10 start
mem[8'h14] = 16'h0000; // 00
mem[8'h15] = 16'h0001; // 01
mem[8'h16] = 16'h0003; // 11 sda 1
mem[8'h17] = 16'h0001; // 01
mem[8'h18] = 16'h0000; // 00
mem[8'h19] = 16'h0002; // 10 sda 10
mem[8'h1A] = 16'h0000; // 00
mem[8'h1B] = 16'h0002; // 10 sda 100
mem[8'h1C] = 16'h0000; // 00
mem[8'h1D] = 16'h0001; // 01
mem[8'h1E] = 16'h0003; // 11 sda 1001
mem[8'h1F] = 16'h0001; // 01
mem[8'h20] = 16'h0000; // 00
mem[8'h21] = 16'h0002; // 10 sda 10010
mem[8'h22] = 16'h0000; // 00
mem[8'h23] = 16'h0001; // 01
mem[8'h24] = 16'h0003; // 11 sda 100101
mem[8'h25] = 16'h0001; // 01
mem[8'h26] = 16'h0003; // 11 sda 1001011 .. 0x4B
mem[8'h27] = 16'h0001; // 01
mem[8'h28] = 16'h0000; // 00
mem[8'h29] = 16'h0002; // 10 send 0 ... write
mem[8'h2A] = 16'h0000; // 00
mem[8'h2B] = 16'h0001; // 01
mem[8'h2C] = 16'h0003; // 11 read ack
mem[8'h2D] = 16'h0001; // 01
mem[8'h2E] = 16'h0000; // 00
mem[8'h2F] = 16'h0002; // 10 write 0
mem[8'h30] = 16'h0000; // 00
mem[8'h31] = 16'h0002; // 10 write 00
mem[8'h32] = 16'h0000; // 00
mem[8'h33] = 16'h0002; // 10 write 000
mem[8'h34] = 16'h0000; // 00
mem[8'h35] = 16'h0002; // 10 write 0000
mem[8'h36] = 16'h0000; // 00
mem[8'h37] = 16'h0002; // 10 write 00000
mem[8'h38] = 16'h0000; // 00
mem[8'h39] = 16'h0002; // 10 write 000000
mem[8'h3A] = 16'h0000; // 00
mem[8'h3B] = 16'h0002; // 10 write 0000000
mem[8'h3C] = 16'h0000; // 00
mem[8'h3D] = 16'h0002; // 10 write 00000000 .......
mem[8'h3E] = 16'h0000; // 00
mem[8'h3F] = 16'h0001; // 01
mem[8'h40] = 16'h0003; // 11 read ack
mem[8'h41] = 16'h0001; // 01
mem[8'h42] = 16'h0003; // 11
mem[8'h43] = 16'h0002; // 10 ... repeat start
mem[8'h44] = 16'h0000; // 00
mem[8'h45] = 16'h0001; // 01
mem[8'h46] = 16'h0003; // 11 sda 1
mem[8'h47] = 16'h0001; // 01
mem[8'h48] = 16'h0000; // 00
mem[8'h49] = 16'h0002; // 10 sda 10
mem[8'h4A] = 16'h0000; // 00
mem[8'h4B] = 16'h0002; // 10 sda 100
mem[8'h4C] = 16'h0000; // 00
mem[8'h4D] = 16'h0001; // 01
mem[8'h4E] = 16'h0003; // 11 sda 1001
mem[8'h4F] = 16'h0001; // 01
mem[8'h50] = 16'h0000; // 00
mem[8'h51] = 16'h0002; // 10 sda 10010
mem[8'h52] = 16'h0000; // 00
mem[8'h53] = 16'h0001; // 01
mem[8'h54] = 16'h0003; // 11 sda 100101
mem[8'h55] = 16'h0001; // 01
mem[8'h56] = 16'h0003; // 11 sda 1001011 .. 0x4B
mem[8'h57] = 16'h0001; // 01
mem[8'h58] = 16'h0003; // 11 send 1 ... read
mem[8'h59] = 16'h0001; // 01
mem[8'h5A] = 16'h0003; // 11 read ack
mem[8'h5B] = 16'h0001; // 01
mem[8'h5C] = 16'h0003; // 11 read 1st bit
mem[8'h5D] = 16'h0001; // 01
mem[8'h5E] = 16'h0003; // 11 read 2nd bit
mem[8'h5F] = 16'h0001; // 01
mem[8'h60] = 16'h0003; // 11 read 3rd bit
mem[8'h61] = 16'h0001; // 01
mem[8'h62] = 16'h0003; // 11 read 4th bit
mem[8'h63] = 16'h0001; // 01
mem[8'h64] = 16'h0003; // 11 read 5th bit
mem[8'h65] = 16'h0001; // 01
mem[8'h66] = 16'h0003; // 11 read 6th bit
mem[8'h67] = 16'h0001; // 01
mem[8'h68] = 16'h0003; // 11 read 7th bit
mem[8'h69] = 16'h0001; // 01
mem[8'h6A] = 16'h0003; // 11 read 8th bit
mem[8'h6B] = 16'h0001; // 01
mem[8'h6C] = 16'h0000; // 00
mem[8'h6D] = 16'h0002; // 10 write ack
mem[8'h6E] = 16'h0000; // 00
mem[8'h6F] = 16'h0001; // 01
mem[8'h70] = 16'h0003; // 11 read ack
mem[8'h71] = 16'h0001; // 01
mem[8'h72] = 16'h0003; // 11 read 1st bit
mem[8'h73] = 16'h0001; // 01
mem[8'h74] = 16'h0003; // 11 read 2nd bit
mem[8'h75] = 16'h0001; // 01
mem[8'h76] = 16'h0003; // 11 read 3rd bit
mem[8'h77] = 16'h0001; // 01
mem[8'h78] = 16'h0003; // 11 read 4th bit
mem[8'h79] = 16'h0001; // 01
mem[8'h7A] = 16'h0003; // 11 read 5th bit
mem[8'h7B] = 16'h0001; // 01
mem[8'h7C] = 16'h0003; // 11 read 6th bit
mem[8'h7D] = 16'h0001; // 01
mem[8'h7E] = 16'h0003; // 11 read 7th bit
mem[8'h7F] = 16'h0001; // 01
mem[8'h80] = 16'h0003; // 11 read 8th bit
mem[8'h81] = 16'h0001; // 01
mem[8'h82] = 16'h0003; // 11 write NACK
mem[8'h83] = 16'h0001; // 01
mem[8'h84] = 16'h0000; // 00
mem[8'h85] = 16'h0002; // 10
mem[8'h86] = 16'h0003; // 11 stop the transfering
mem[8'h87] = 16'h0001; // 01
end
endmodule
* 実行 [#xa8f59dd]
- start up clock を jtag に設定し、bitファイルを生成し、...
- 7segment LEDの表示が 0000 0000 になります(sw で異なりま...
- BD(下 or 南)ボタンを押すとリセットされ、動作モードが0に...
- 動作モードが 0 のとき(bitファイルをボードに書き込んだ直...
- BE(右 or 東)ボタンを押すごとに動作モード1ずつ増えて変わ...
- 動作モードが2のときは、Color LED 1の色が 緑になります。...
I2Cからの入力は、、「[[I2Cデバイスを手で動かしてみる]]」...
* 考察 [#aedb8465]
- クロックの供給は手入力なので、大変。クロックも自動的に...
- プログラムでサブルーチンを利用したい。サブルーチンを利...
----
#counter
終了行:
[[MenuBar]]
* 概要 [#zaba5b6a]
- miniCPU をI2Cのmaster device として、I2Cのslave device ...
- 動作モードを変更することにより、I2Cのslave device を手...
- 動作モードの変更は、5つのボタンの、左右(西と東)を使っ...
- miniCPUのクロックは、中央のボタンを押したり離したりして...
- miniCPUでI2Cの slave device を動かしているとき、miniCPU...
* 回路の概要 [#oe8fa2dd]
- miniCPU を構成する部品は、[[MiniCPU]]のものをそのまま使...
- 「[[I2Cデバイスを手で動かしてみる]]」の回路を拡張して、...
- sw[15:0]と up button, left button, center button, right...
- sclx が1のときは、sclはZ(high impedance), sclxが0のとき...
- sdax が1のときは、sdaはZ(high impedance), sclxが0のとき...
- 動作モードを表すレジスタ, operationMode を使います。ope...
-- 動作モードをカラーLED 1で表示します。
-- 動作モード 0 のときは、miniCPUのクロック(cpuCLK)や run...
-- 動作モード 1 のときは、BCxを miniCPUのクロックに接続し...
-- 動作モード 2 のときは, BCxを miniCPUのクロックに接続し...
- 動作モードの表 &br;
|operationMode |Color LED 1|cpuClk|cpuRun|cpuIn|sSegArray...
|0| {0,0,0} | 0 | 0 | 0| {16{0}, data,swx[7:0]}|{data,swx...
|1|{0,0,1}|BCx|BNx|swx|{{0},cpuCs,pcout,irout}|out|1,1|{0...
|2|{0,1,0}|BCx|BNx|{8{0},data}|{{0},cpuCs,abus,dbus}|{dat...
- down button をリセット信号とします。
- sda を led[8] に接続します。scl が 0->1 に変化するたび...
- 1つのポートで入出力を行う為、scl, sda は verilog の in...
* verilog [#l41887fa]
- [[MiniCPU]] の top.v と ram.v を以下の verilog で置き換...
- 以下の ram.v は、ADT7420 で計測された温度を取得し, led ...
- top.v
module top(sSegAnode, sSegCathode, sw, ledOut, colorLed_...
bu, bd, bl, br, bc, scl, sda,
bclck
);
output [7:0] sSegAnode;
output [7:0] sSegCathode;
output [15:0] ledOut; // led[8] ... if sd...
// else ...
// it i...
// led[0] correspond...
// led[1] corresponding to sw[1]
// led[2] corresponsing to center button, ...
output [2:0] colorLed_1;
output [2:0] colorLed_2; // color LED
input [15:0] sw; // sw[15:8] ... for ...
// sw[0] ... if 1...
// sw[1] ... if 1 sda is receiving(1), e...
// sw[2] ... sending sda.
input bu, bd, bl, br, bc, bclck; // bd corresponding...
// bc corresponding...
// if posedge bl is detected, sw is shown i...
inout scl, sda;
reg sclx, sdax;
assign scl=(~sclx)?1'b0:1'bz;
assign sda=(~sdax)?1'b0:1'bz;
wire BNx, BWx, BEx, BCx;
// reset: BSx
// BWx, BEx ... change operationMode
//
wire [15:0] swx;
wire reset;
// reg sclRw, sdaRw; // write=1, read=0;
reg cpuClk,cpuRun;
reg [7:0] data;
reg [1:0] operationMode;
// operationMode: 0 ... manual operation of peripherals
// 1 ... CPU independent
// 2 ... CPU, I2C connected
reg [15:0] ledWire,cpuIn;
wire [2:0] cpuCs;
wire [11:0] pcout,abus;
wire [15:0] irout,qtop,dbus,out;
reg [31:0] sSegArray;
reg [15:0] led;
assign ledOut=led;
reg [2:0] colorLed_1x, colorLed_2x;
//
assign colorLed_1=colorLed_1x;
// assign colorLed_2=colorLed_2x;
assign reset=~bd;
// always @(sclx or sdax ) begin
// colorLed_2x[0]<=sclx;
// colorLed_2x[1]<=sdax;
// colorLed_2x[2]<=0;
// end
assign colorLed_2={0,sda,scl};
always @(posedge sclx, negedge reset) begin
if(!reset) begin
data<=0;
end
else
data<={data[6:0],sda};
end
// for operation mode
always @(posedge BEx or negedge reset) begin
if(!reset) begin
operationMode<=0;
end
else
if(BEx) operationMode<=operationMode+1;
end
// always @(operationMode or swx[0] or BCx or data or B...
always @(operationMode) begin
case(operationMode)
0: begin
colorLed_1x=3'b000;
cpuClk=0; cpuRun=0; cpuIn=0;
sSegArray={{16{0}},data,swx[7:0]};
led[15:8]=data;
led[7:0]=swx[7:0];
sclx=BCx;
sdax=swx[0];
end
1: begin // CPU independent,
colorLed_1x=3'b001;
cpuClk=BCx; cpuRun=BNx; cpuIn=swx;
sSegArray={{0},cpuCs,pcout,irout};
led={{0{16}},out};
sclx=1'b1;
sdax=1'b1;
end
2: begin
colorLed_1x=3'b010;
cpuClk=BCx; cpuRun=BNx; cpuIn={{8{0}},data};
sSegArray={{0},cpuCs,abus,dbus};
led[15:8]=data;
led[7:0]=out[7:0];
sclx=out[1];
sdax=out[0];
end
default begin
colorLed_1x=3'b011;
cpuClk=BCx; cpuRun=BNx; cpuIn=swx;
sSegArray={{0{16}},data,swx[7:0]};
led[15:8]=data;
led[7:0]=swx[7:0];
sclx=BCx;
sdax=swx[0];
end
endcase
end
chattering #(20) chattering0(.clk(bclck), .reset(reset...
// assign BNx=bu;
// assign BWx=bl;
// assign BEx=br;
// assign BCx=bc;
// assign swx=sw;
sSegArray sSegArray0(.clk(bclck), .reset(reset), .load(...
minicpu minicpu0(.clk(cpuClk), .reset(reset), .run(cpu...
endmodule
- ram0
module ram(clk, load, addr, d, q
);
parameter DWIDTH=16, AWIDTH=12, WORDS=4096;
input clk, load;
input [AWIDTH-1:0] addr;
input [DWIDTH-1:0] d;
output [DWIDTH-1:0] q;
reg [DWIDTH-1:0] q;
reg [DWIDTH-1:0] mem [WORDS-1:0];
always @(posedge clk)
begin
if(load) mem[addr] <= d;
q <= mem[addr];
end
integer i;
initial begin
for(i=0; i<WORDS; i=i+1)
mem[i]=12'h000;
mem[8'h00] = 16'h1000; // PUSHI 0
mem[8'h01] = 16'h3011; // POP i ... i=0;
mem[8'h02] = 16'h2011; // L1 PUSH i
mem[8'h03] = 16'h1012; // PUSHI C
mem[8'h04] = 16'hF000; // ADD
mem[8'h05] = 16'h7000; // LD ... C[i];
mem[8'h06] = 16'hE000; // OUT ... print(C[i]) ;
mem[8'h07] = 16'h2011; // PUSH i;
mem[8'h08] = 16'h1001; // PUSH 1
mem[8'h09] = 16'hF000; // ADD
mem[8'h0A] = 16'h3011; // POP i
mem[8'h0B] = 16'h2011; // PUSH i
mem[8'h0C] = 16'h2010; // PUSH n
mem[8'h0D] = 16'hF001; // SUB
mem[8'h0E] = 16'h6002; // JNZ L1: if(i<n) goto L1;
mem[8'h0F] = 16'h0000; // L2: HALT
mem[8'h10] = 16'h0076; // n: 0x76 ... 0x88-0x12
mem[8'h11] = 16'h0000; // i:
//
// data for controlling i2c
// (MSB) ...... scl, sda (LSB)
mem[8'h12] = 16'h0003; // C: 11
mem[8'h13] = 16'h0002; // 10 start
mem[8'h14] = 16'h0000; // 00
mem[8'h15] = 16'h0001; // 01
mem[8'h16] = 16'h0003; // 11 sda 1
mem[8'h17] = 16'h0001; // 01
mem[8'h18] = 16'h0000; // 00
mem[8'h19] = 16'h0002; // 10 sda 10
mem[8'h1A] = 16'h0000; // 00
mem[8'h1B] = 16'h0002; // 10 sda 100
mem[8'h1C] = 16'h0000; // 00
mem[8'h1D] = 16'h0001; // 01
mem[8'h1E] = 16'h0003; // 11 sda 1001
mem[8'h1F] = 16'h0001; // 01
mem[8'h20] = 16'h0000; // 00
mem[8'h21] = 16'h0002; // 10 sda 10010
mem[8'h22] = 16'h0000; // 00
mem[8'h23] = 16'h0001; // 01
mem[8'h24] = 16'h0003; // 11 sda 100101
mem[8'h25] = 16'h0001; // 01
mem[8'h26] = 16'h0003; // 11 sda 1001011 .. 0x4B
mem[8'h27] = 16'h0001; // 01
mem[8'h28] = 16'h0000; // 00
mem[8'h29] = 16'h0002; // 10 send 0 ... write
mem[8'h2A] = 16'h0000; // 00
mem[8'h2B] = 16'h0001; // 01
mem[8'h2C] = 16'h0003; // 11 read ack
mem[8'h2D] = 16'h0001; // 01
mem[8'h2E] = 16'h0000; // 00
mem[8'h2F] = 16'h0002; // 10 write 0
mem[8'h30] = 16'h0000; // 00
mem[8'h31] = 16'h0002; // 10 write 00
mem[8'h32] = 16'h0000; // 00
mem[8'h33] = 16'h0002; // 10 write 000
mem[8'h34] = 16'h0000; // 00
mem[8'h35] = 16'h0002; // 10 write 0000
mem[8'h36] = 16'h0000; // 00
mem[8'h37] = 16'h0002; // 10 write 00000
mem[8'h38] = 16'h0000; // 00
mem[8'h39] = 16'h0002; // 10 write 000000
mem[8'h3A] = 16'h0000; // 00
mem[8'h3B] = 16'h0002; // 10 write 0000000
mem[8'h3C] = 16'h0000; // 00
mem[8'h3D] = 16'h0002; // 10 write 00000000 .......
mem[8'h3E] = 16'h0000; // 00
mem[8'h3F] = 16'h0001; // 01
mem[8'h40] = 16'h0003; // 11 read ack
mem[8'h41] = 16'h0001; // 01
mem[8'h42] = 16'h0003; // 11
mem[8'h43] = 16'h0002; // 10 ... repeat start
mem[8'h44] = 16'h0000; // 00
mem[8'h45] = 16'h0001; // 01
mem[8'h46] = 16'h0003; // 11 sda 1
mem[8'h47] = 16'h0001; // 01
mem[8'h48] = 16'h0000; // 00
mem[8'h49] = 16'h0002; // 10 sda 10
mem[8'h4A] = 16'h0000; // 00
mem[8'h4B] = 16'h0002; // 10 sda 100
mem[8'h4C] = 16'h0000; // 00
mem[8'h4D] = 16'h0001; // 01
mem[8'h4E] = 16'h0003; // 11 sda 1001
mem[8'h4F] = 16'h0001; // 01
mem[8'h50] = 16'h0000; // 00
mem[8'h51] = 16'h0002; // 10 sda 10010
mem[8'h52] = 16'h0000; // 00
mem[8'h53] = 16'h0001; // 01
mem[8'h54] = 16'h0003; // 11 sda 100101
mem[8'h55] = 16'h0001; // 01
mem[8'h56] = 16'h0003; // 11 sda 1001011 .. 0x4B
mem[8'h57] = 16'h0001; // 01
mem[8'h58] = 16'h0003; // 11 send 1 ... read
mem[8'h59] = 16'h0001; // 01
mem[8'h5A] = 16'h0003; // 11 read ack
mem[8'h5B] = 16'h0001; // 01
mem[8'h5C] = 16'h0003; // 11 read 1st bit
mem[8'h5D] = 16'h0001; // 01
mem[8'h5E] = 16'h0003; // 11 read 2nd bit
mem[8'h5F] = 16'h0001; // 01
mem[8'h60] = 16'h0003; // 11 read 3rd bit
mem[8'h61] = 16'h0001; // 01
mem[8'h62] = 16'h0003; // 11 read 4th bit
mem[8'h63] = 16'h0001; // 01
mem[8'h64] = 16'h0003; // 11 read 5th bit
mem[8'h65] = 16'h0001; // 01
mem[8'h66] = 16'h0003; // 11 read 6th bit
mem[8'h67] = 16'h0001; // 01
mem[8'h68] = 16'h0003; // 11 read 7th bit
mem[8'h69] = 16'h0001; // 01
mem[8'h6A] = 16'h0003; // 11 read 8th bit
mem[8'h6B] = 16'h0001; // 01
mem[8'h6C] = 16'h0000; // 00
mem[8'h6D] = 16'h0002; // 10 write ack
mem[8'h6E] = 16'h0000; // 00
mem[8'h6F] = 16'h0001; // 01
mem[8'h70] = 16'h0003; // 11 read ack
mem[8'h71] = 16'h0001; // 01
mem[8'h72] = 16'h0003; // 11 read 1st bit
mem[8'h73] = 16'h0001; // 01
mem[8'h74] = 16'h0003; // 11 read 2nd bit
mem[8'h75] = 16'h0001; // 01
mem[8'h76] = 16'h0003; // 11 read 3rd bit
mem[8'h77] = 16'h0001; // 01
mem[8'h78] = 16'h0003; // 11 read 4th bit
mem[8'h79] = 16'h0001; // 01
mem[8'h7A] = 16'h0003; // 11 read 5th bit
mem[8'h7B] = 16'h0001; // 01
mem[8'h7C] = 16'h0003; // 11 read 6th bit
mem[8'h7D] = 16'h0001; // 01
mem[8'h7E] = 16'h0003; // 11 read 7th bit
mem[8'h7F] = 16'h0001; // 01
mem[8'h80] = 16'h0003; // 11 read 8th bit
mem[8'h81] = 16'h0001; // 01
mem[8'h82] = 16'h0003; // 11 write NACK
mem[8'h83] = 16'h0001; // 01
mem[8'h84] = 16'h0000; // 00
mem[8'h85] = 16'h0002; // 10
mem[8'h86] = 16'h0003; // 11 stop the transfering
mem[8'h87] = 16'h0001; // 01
end
endmodule
* 実行 [#xa8f59dd]
- start up clock を jtag に設定し、bitファイルを生成し、...
- 7segment LEDの表示が 0000 0000 になります(sw で異なりま...
- BD(下 or 南)ボタンを押すとリセットされ、動作モードが0に...
- 動作モードが 0 のとき(bitファイルをボードに書き込んだ直...
- BE(右 or 東)ボタンを押すごとに動作モード1ずつ増えて変わ...
- 動作モードが2のときは、Color LED 1の色が 緑になります。...
I2Cからの入力は、、「[[I2Cデバイスを手で動かしてみる]]」...
* 考察 [#aedb8465]
- クロックの供給は手入力なので、大変。クロックも自動的に...
- プログラムでサブルーチンを利用したい。サブルーチンを利...
----
#counter
ページ名: