Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7130117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:18:57+00:00 2026-05-28T11:18:57+00:00

Forgive a newbie, I don’t even know how to ask this question properly: I

  • 0

Forgive a newbie, I don’t even know how to ask this question properly:

I have a file which is currently loaded into a memory bank, and I’d like to split it across four different memory banks.

I have some system verilog code which uses a line very like this:

$readmemh(mem_file, memories.ram);

to read in a hex file (say it’s 65536 bytes long) to some memory.

Now I want to split the memory into four parts, and put the first quarter (16384 bytes) into a block, the second quarter into another, etc…

One obvious way to do this is to split the hex file using head, tail, etc, as part of the build process that makes it, and then pass in all the new filenames at simulation time, and have statements like

$readmemh(mem_file_1stbit, memories.ram1);
$readmemh(mem_file_2ndbit, memories.ram2);
$readmemh(mem_file_3rdbit, memories.ram3);
$readmemh(mem_file_4thbit, memories.ram4);

But that seems to couple the firmware build process, simulation script, and verilog design far too much for my taste.

A greatly superior solution (in my opinion), would be to modify the verilog code to say something like:

$readmemh(mem_file, memories.ram1, 0,       (1<<14)-1);
$readmemh(mem_file, memories.ram2, (1<<14), (2<<14)-1);
$readmemh(mem_file, memories.ram3, (2<<14), (3<<14)-1);
$readmemh(mem_file, memories.ram4, (3<<14), (4<<14)-1);

But it doesn’t look like verilog will let me do this sort of thing.

Can anyone come up with a neat construction that will achieve the same result?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T11:18:58+00:00Added an answer on May 28, 2026 at 11:18 am

    This little snippet seems to do the business. It does introduce an intermediate load of stuff that I rather hope won’t end up getting synthesised.

    I’ll go with this sort of thing. If anyone who actually knows what they’re doing wants to tell me why this is a bad idea, I’d be most grateful.

       reg [8:0] data [0:15];
       reg [8:0] data1 [0:7];
       reg [8:0] data2 [0:7];
    
       integer   i;
    
       initial begin
          $readmemh("data.hex", data);
          for(i=0; i<16; i=i+1) 
            $display("%d:%h",i,data[i]);
          for(i=0; i<8; i=i+1)
            begin
               data1[i]=data[i];
               data2[i]=data[i+8];
            end
       end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Forgive me for this basic question. I have loaded a set of data as
Forgive me if this is a stupid question, I know there have been similar
Please forgive the newbie question. I have an iphone game that currently uses lots
Forgive the complete newbie question here - I know this is really basic stuff,
This is simple question but I am a newbie so please forgive my simple
I'm a newbie at Scheme, so forgive the question: I have a function that
Forgive my ignorance if this is 'a basic question'..... I have a method that
I am an android newbie so forgive me if this question is simple. Basically
Forgive me if this is a newbie question, but... When playing video, is it
Forgive me if this is a newbie question: I've got a menu set to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.