?? instr_memory.h
字號:
#ifndef INSTR_MEMORY_H
#define INSTR_MEMORY_H
#include "STDAFX.h"
//指令寄存器
SC_MODULE(Instr_Memory)
{
//輸入指令地址
sc_in<sc_uint<32> > address;
//輸出指令
sc_out<sc_uint<32> > instr;
//指令內存
sc_uint<32> instr_data[1024];
//
void entry()
{
//next_trigger(100,SC_NS);
unsigned int add=address.read()/4;
if (add>=1024) return;
instr.write(instr_data[add]);
}
void Input()
{
cout<<"請每行輸入一條指令,用unsigned int 表示。輸入行為#時表示指令結束"<<endl;
char currentInstr[1000];
int i=0;
unsigned int temp;
while (true)
{
std::cin.getline(currentInstr,500,'\n');
if (currentInstr[0]=='#') break;
i++;
if (currentInstr[0]=='=')
sscanf(currentInstr+1,"%ud",&temp);
else
sscanf(currentInstr,"%ud",&temp);
instr_data[i]=temp;
}
}
//構造函數
SC_CTOR(Instr_Memory)
{
SC_METHOD(entry);
sensitive<<address;
int i;
for (i=0;i<1024;++i) instr_data[i]=0;
}
};
/*
//測試模塊
SC_MODULE(test_Instr_Memory)
{
sc_out<sc_uint<32> > address;
sc_in<sc_uint<32> > instr;
void test()
{
int i;
cout<<0<<":";
address.write(0);
wait();
Print(instr.read());
cout<<1<<":";
address.write(1);
wait();
Print(instr.read());
cout<<2<<":";
address.write(2);
wait();
Print(instr.read());
}
SC_CTOR(test_Instr_Memory)
{
SC_THREAD(test);
sensitive<<instr;
//dont_initialize();
}
};
//測試函數
void test_Memory_Instruction()
{
Instr_Memory instr_memory("Instr_Memory");
test_Instr_Memory test("test_Instr_Memory");
sc_signal<sc_uint<32> > address,instr;
instr_memory.address(address);
instr_memory.instr(instr);
test.address(address);
test.instr(instr);
sc_start(100);
}
*/
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -