6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 22, 2024 6:21 am

All times are UTC




Post new topic Reply to topic  [ 48 posts ]  Go to page Previous  1, 2, 3, 4
Author Message
PostPosted: Sun Mar 22, 2020 6:04 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
I've forgotten how to implement this whole process! How do we invoke data2mem?
I understood the part of finding and LOCing down the 'ROM' using PlanAhead... I guess my main question, as I do have an old project with the command line additions form .bmm and .mem, how do we start the process?

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502


Top
 Profile  
Reply with quote  
PostPosted: Sun Oct 10, 2021 7:17 pm 
Offline

Joined: Tue Sep 03, 2002 12:58 pm
Posts: 336
I've finally got around to getting this set up for my own design. I don't use the IDE, so this is all based on the command line.

First, I have all of my ROMs explicitly instantiated as BRAMs (RAMB16BWER). There's no need to lock these to particular positions - the tools handle that automatically. In my case, I have a 4K*16 ROM for the character bitmaps, and an 8K*16 ROM for the 'kernal' (my project is a descendant of the Commodore 64, so I've taken the traditional name and spelling).
The character ROM is implemented as 4 BRAMs, each contributing 4 bits of the output word. The kernal ROM is 8 BRAMs, each contributing 2 bits.

Here's the .bmm file:
Code:
ADDRESS_SPACE char RAMB16 [0x00000000:0x00001fff]
   BUS_BLOCK
      C640_INST/MEM_INST/CHARROM_INST/CHARROM_3_INST [15:12];
      C640_INST/MEM_INST/CHARROM_INST/CHARROM_2_INST [11:8];
      C640_INST/MEM_INST/CHARROM_INST/CHARROM_1_INST [7:4];
      C640_INST/MEM_INST/CHARROM_INST/CHARROM_0_INST [3:0];
   END_BUS_BLOCK;
END_ADDRESS_SPACE;
ADDRESS_SPACE kernal RAMB16 [0x00000000:0x00003fff]
   BUS_BLOCK
      C640_INST/MEM_INST/KERNALROM_INST/KERNALROM_7_INST [15:14];
      C640_INST/MEM_INST/KERNALROM_INST/KERNALROM_6_INST [13:12];
      C640_INST/MEM_INST/KERNALROM_INST/KERNALROM_5_INST [11:10];
      C640_INST/MEM_INST/KERNALROM_INST/KERNALROM_4_INST [9:8];
      C640_INST/MEM_INST/KERNALROM_INST/KERNALROM_3_INST [7:6];
      C640_INST/MEM_INST/KERNALROM_INST/KERNALROM_2_INST [5:4];
      C640_INST/MEM_INST/KERNALROM_INST/KERNALROM_1_INST [3:2];
      C640_INST/MEM_INST/KERNALROM_INST/KERNALROM_0_INST [1:0];
   END_BUS_BLOCK;
END_ADDRESS_SPACE;

Each line in the BUS_BLOCKs specifies one of the BRAMs. There's a range of bits in square brackets for each, but this is not used for inserting data into the bitstream. Instead, the order of BRAMs is used. Data from the .mem file is read N bits at a time, and placed into the BRAMs in the order they appear in the .bmm file. So they have to be given high bits first (the alternative is to swap the bits around in the .mem file). The address range in the ADDRESS_SPACE lines is given in bytes, so although my character ROM is 4K*16, I have to say that it's 8K bytes. There might be better way to handle this, but I haven't found it.

Next, the contents of the .bmm file must be included in the design. This is done by adding "-bm source/c640.bmm" to the command line for ngdbuild. At the end of the build process, bitgen will create a new .bmm file called "c640_bd.bmm". This contains the same definitions as the originals, but has the locations of each BRAM attached. This is the file used by data2mem.

The data to be placed into the BRAMs goes in .mem files. Here's my current one for the kernal ROM:
Code:
@00000000 00a2 00ff 009a 0020 0050 00e1 90f0 0153
          00a9 0000 0085 0400 00a9 0030 0085 07c0
          00a9 0001 0085 dbc0 01a2 03e7 20a9 000e
          ...
          0000 0000 00b6 00ea 0000 00e0 00d0 00ea

(My CPU is an extended 6502 with a 16 bit data bus; that's why there are 6502 opcodes in the bottom half of the words)

I'm lying to the software here, telling it that my ROMs are both at address 0. Since they're in different address spaces, they don't overlap. I couldn't work out how to tell it that my ROMs are 16 bits wide, so it's counting everything in bytes. The addresses will all be wrong anyway, so I might as well tell it that they start at 0.

Finally, data2mem is used to insert the contents of the .mem files into the bitstream. Here's the command for that:
Code:
data2mem -bm source/c640_bd.bmm -bd source/kernalrom.mem tag kernal -bt build/c640.bit -o b build/c640_final.bit

The tag identifies which address space this data goes into. It's the name given in the ADDRESS_SPACE line. The original bitstream is read from c640.bit, and the new one is written to c640_final.bit. It seems you can't give the same file for these - the original will get deleted before anything is read from it.

This saves so much time. Instead of waiting minutes for the whole design to resynthesise, I can have new code running on the FPGA board in a few seconds.


Top
 Profile  
Reply with quote  
PostPosted: Sun Oct 10, 2021 8:15 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
Excellent, thanks for the detailed commands.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 48 posts ]  Go to page Previous  1, 2, 3, 4

All times are UTC


Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: