OpenCores
URL https://opencores.org/ocsvn/vtach/vtach/trunk

Subversion Repositories vtach

[/] [vtach/] [trunk/] [memory.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wd5gnr
`timescale 1us/1us
2
// Interface to a Xilinx block RAM
3
// The clk should be 2x what the rest of the system is using
4
// So that the output is ready at the start of the next cycle.
5
// Bit 12 is sign, Bits 11-0 are BCD data
6
module memory(input clk,input [7:0]memaddr, inout [12:0] dbus, input memoe, input memwrite);
7
// Input address is BCD!
8
        wire [6:0] binaddress;
9
   wire [12:0] outdata;   // current output word
10
 
11
// Drive DBUS when asked
12
   assign dbus=memoe?outdata:13'bz;
13
// convert BCD address to binary
14
// binaddress=10*digit1 + digit 0 
15
//  or 8*digit1+2*digit1+digit0
16
        assign binaddress=({3'b0, memaddr[7:4]}<<3)+({3'b0, memaddr[7:4]}<<1)+{ 3'b0, memaddr[3:0]};
17
 
18
mainmem ram (
19
  .clka(clk), // input clka
20
  .wea(memwrite), // input [0 : 0] wea
21
  .addra(binaddress), // input [6 : 0] addra
22
  .dina(dbus), // input [12 : 0] dina
23
  .douta(outdata) // output [12 : 0] douta
24
);
25
 
26
 
27
 
28
 
29
  endmodule
30
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.