@@ -327,9 +327,9 @@ sim_data_t *init_simulation(netlist_t *netlist)
327
327
{
328
328
// for multithreading
329
329
used_time = std::numeric_limits<double >::max ();
330
- number_of_workers = std::min (CONCURENCY_LIMIT, std::max ( 1 , global_args.parralelized_simulation .value ()) );
331
- if (global_args. parralelized_simulation . value () >1 )
332
- warning_message (SIMULATION_ERROR,-1 ,-1 ," Executing simulation with maximum of %d threads" , global_args. parralelized_simulation . value () );
330
+ number_of_workers = global_args.parralelized_simulation .value ();
331
+ if (number_of_workers >1 )
332
+ warning_message (SIMULATION_ERROR,-1 ,-1 ," Executing simulation with maximum of %d threads" , number_of_workers );
333
333
334
334
335
335
found_best_time = false ;
@@ -2118,18 +2118,20 @@ static void read_write_to_memory(nnode_t *node , signal_list_t *input_address, s
2118
2118
* make a single trigger out of write_enable pin and if it was a positive edge
2119
2119
*/
2120
2120
bool write = (trigger && 1 == get_pin_value (write_enabled, cycle));
2121
+ bool address_is_valid = (address >= 0 && address < node->memory_data .size ());
2121
2122
2122
- std::vector<signed char > previous_values = node->memory_data ->get_word_line (address, cycle-1 );
2123
- std::vector<signed char > new_values;
2124
2123
for (size_t i = 0 ; i < data_out->count ; i++)
2125
2124
{
2126
- // we hook onto the ff function to both read and update since memories are flip flops
2127
- new_values.push_back (compute_ff (write, data_in->pins [i], previous_values[i], cycle));
2125
+ signed char new_value = -1 ;
2126
+ if (address_is_valid)
2127
+ {
2128
+ // we hook onto the ff function to both read and update since memories are flip flops
2129
+ new_value = compute_ff (write, data_in->pins [i], node->memory_data [address][i], cycle);
2130
+ node->memory_data [address][i] = new_value;
2131
+ }
2128
2132
// output is combinational so it always grabs latest value
2129
- update_pin_value (data_out->pins [i], new_values. back () , cycle);
2133
+ update_pin_value (data_out->pins [i], new_value , cycle);
2130
2134
}
2131
-
2132
- node->memory_data ->set_word_line (address, new_values, cycle);
2133
2135
}
2134
2136
2135
2137
/*
@@ -2141,10 +2143,9 @@ static void compute_single_port_memory(nnode_t *node, int cycle)
2141
2143
2142
2144
bool trigger = ff_trigger (RISING_EDGE_SENSITIVITY, signals->clk , cycle);
2143
2145
2144
- if (node->memory_data == nullptr || node-> memory_data -> empty ())
2146
+ if (node->memory_data . empty ())
2145
2147
instantiate_memory (node, signals->data ->count , signals->addr ->count );
2146
2148
2147
- node->memory_data ->copy_ram_foward_one_cycle (cycle);
2148
2149
2149
2150
read_write_to_memory (node, signals->addr , signals->out , signals->data , trigger, signals->we , cycle);
2150
2151
@@ -2159,13 +2160,12 @@ static void compute_dual_port_memory(nnode_t *node, int cycle)
2159
2160
dp_ram_signals *signals = get_dp_ram_signals (node);
2160
2161
bool trigger = ff_trigger (RISING_EDGE_SENSITIVITY, signals->clk , cycle);
2161
2162
2162
- if (node->memory_data == nullptr || node-> memory_data -> empty ())
2163
+ if (node->memory_data . empty ())
2163
2164
instantiate_memory (node,
2164
2165
std::max (signals->data1 ->count , signals->data2 ->count ),
2165
2166
std::max (signals->addr1 ->count ,signals->addr2 ->count )
2166
2167
);
2167
2168
2168
- node->memory_data ->copy_ram_foward_one_cycle (cycle);
2169
2169
2170
2170
read_write_to_memory (node, signals->addr1 , signals->out1 , signals->data1 , trigger, signals->we1 , cycle);
2171
2171
read_write_to_memory (node, signals->addr2 , signals->out2 , signals->data2 , trigger, signals->we2 , cycle);
@@ -2179,7 +2179,8 @@ static void compute_dual_port_memory(nnode_t *node, int cycle)
2179
2179
*/
2180
2180
static void instantiate_memory (nnode_t *node, int data_width, int addr_width)
2181
2181
{
2182
- node->memory_data = std::make_unique<AtomicRam>(addr_width, data_width, init_value (node));
2182
+ long max_address = 1 << addr_width;
2183
+ node->memory_data = std::vector<std::vector<signed char >>(max_address, std::vector<signed char >(data_width, init_value (node)));
2183
2184
char *filename = get_mif_filename (node);
2184
2185
2185
2186
FILE *mif = fopen (filename, " r" );
@@ -2305,7 +2306,8 @@ static void assign_memory_from_mif_file(nnode_t *node, FILE *mif, char *filename
2305
2306
error_message (SIMULATION_ERROR, line_number, -1 , " %s: address %s is out of range." , filename, address_string);
2306
2307
2307
2308
// Write the parsed value string to the memory location.
2308
- node->memory_data ->init_word_line (address, binary_data, width);
2309
+ for (int i=0 ; i<width; i++)
2310
+ node->memory_data [address][i] = binary_data[i] - ' 0' ;
2309
2311
}
2310
2312
else
2311
2313
{
0 commit comments