Maker Pro
Maker Pro

how to write input and output for microcontroller ?

hello experts
I want to write input and output for microcontroller in verilog langugae

I have tried to write code

Microcontroller has following function

· ALU

· Decoder

· Port

· Counter

· Interrupt

· Accumulator

· Stack pointer

· Data pointer

· Special function register

· Serial communication

· Internal rom

· External rom

· Internal ram

· External Ram


Verilog code

Code:
Module mcu (clk, rst, en, p_in, p_out, t_in, t_out, i_in,i_out, rx_in, tx_out ,a0,a1,a2,d0,d1,d2,d3,d4,d5,d6,d7,a,b,s0,s1,s2,f,........etc);
Rst= reset input
Clk=  clock input
En= enable input

Port
P_in=port input
P_out= port output

Timer
T_in = timer input
T_out = timer output

Interrupt
i_in= input for interrupt
i_out,= output for interrupt

ALU
A=input
B=input
So=input
S1=input
S2=input
F=output

Decoder
A0=input
A1=input
A2=input
D0=output
D1=output
D2=output
D3=output
D4=output
D5=output
D6=output

Can anyone teach me how to write input and output for microcontroller in verilog langugae ?
 
look at this example

what is meaning of ifdef and endif ?
module oc8051_top (wb_rst_i, wb_clk_i,

//interface to instruction rom

wbi_adr_o,

wbi_dat_i,

wbi_stb_o,

wbi_ack_i,

wbi_cyc_o,

wbi_err_i,


//interface to data ram

wbd_dat_i,

wbd_dat_o,

wbd_adr_o,

wbd_we_o,

wbd_ack_i,

wbd_stb_o,

wbd_cyc_o,

wbd_err_i,


// interrupt interface

int0_i,

int1_i,



// port interface

`ifdef OC8051_PORTS

`ifdef OC8051_PORT0

p0_i,

p0_o,

`endif


`ifdef OC8051_PORT1

p1_i,

p1_o,

`endif


`ifdef OC8051_PORT2

p2_i,

p2_o,

`endif


`ifdef OC8051_PORT3

p3_i,

p3_o,

`endif

`endif


// serial interface

`ifdef OC8051_UART

rxd_i, txd_o,

`endif


// counter interface

`ifdef OC8051_TC01

t0_i, t1_i,

`endif


`ifdef OC8051_TC2

t2_i, t2ex_i,

`endif


// BIST

`ifdef OC8051_BIST

scanb_rst,

scanb_clk,

scanb_si,

scanb_so,

scanb_en,

`endif

// external access (active low)

ea_in

);

can we write this code in this manner ?

Code:
module oc8051_top (wb_rst_i, wb_clk_i,
  wbi_adr_o,
wbi_dat_i,
wbi_stb_o,
wbi_ack_i,
wbi_cyc_o,
wbi_err_i,
  wbd_dat_i,
wbd_dat_o,
  wbd_adr_o,
wbd_we_o,
wbd_ack_i,
  wbd_stb_o,
wbd_cyc_o,
wbd_err_i,
  int0_i,
int1_i,
  `
  p0_i,
  p0_o,
p1_i,
  p1_o,
p2_i,
  p2_o,
p3_i,
  p3_o,
rxd_i, txd_o,
t0_i, t1_i,
  `
  t2_i, t2ex_i,
`
  scanb_rst,
  scanb_clk,
  scanb_si,
  scanb_so,
  scanb_en,
  ea_in
  );
 
Top