Skip to content

Commit

Permalink
2.3.1: minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
acaldero committed Oct 12, 2023
1 parent dc117dd commit 8680cfe
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 84 deletions.
11 changes: 0 additions & 11 deletions repo/examples_set/rv32/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -1021,16 +1021,5 @@
"assembly": "s6e1",
"description": "<span data-langkey='example_06_01'>Test example.</span>",
"testing": true
},
{
"id": "R5E2",
"title": "IEEE 754 (32 bits)",
"type": "<span data-langkey='Special'>Special</span>",
"modes": "newbie,intro,rv",
"hardware": "rv",
"microcode": "rv_base",
"assembly": "s6e7",
"description": "<span data-langkey='example_01_01'>Simple example with fetch, arithmetic instructions, and basic .text segment.</span>",
"testing": true
}
]
11 changes: 0 additions & 11 deletions repo/examples_set/rv32/es_rv.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,5 @@
"assembly": "s6e1",
"description": "<span data-langkey='example_06_01'>Test example.</span>",
"testing": true
},
{
"id": "R5E2",
"title": "IEEE 754 (32 bits)",
"type": "<span data-langkey='Special'>Special</span>",
"modes": "newbie,intro,rv",
"hardware": "rv",
"microcode": "rv_base",
"assembly": "s6e7",
"description": "<span data-langkey='example_01_01'>Simple example with fetch, arithmetic instructions, and basic .text segment.</span>",
"testing": true
}
]
3 changes: 2 additions & 1 deletion repo/microcode/rv32/rv_min.mc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# WepSIM (https://wepsim.github.io/wepsim/)
#

firmware_version=2,
begin
{
fetch: # IR <- MP[PC]
Expand All @@ -14,7 +15,7 @@ begin
}

test {
co=010110,
oc(6:0)=0010110,
nwords=1,
{
(),
Expand Down
24 changes: 13 additions & 11 deletions sim_sw/assembly/README_ng.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,27 @@

## 1) Public API

+ **wsasm_prepare_context(CU_data, options)**
+ **wsasm_prepare_context(CU_data, options) -> context**
* It prepare context from firmware (CU_data) plus the default configuration (options), and it builds the context object to be used in the next steps

+ **wsasm_prepare_source(context, asm_source)**
+ **wsasm_prepare_source(context, asm_source) -> context**
* It prepare context with the source code (asm_source) for the next steps

+ **wsasm_src2obj(context)**
+ **wsasm_src2obj(context) -> ret**
* Assembler API function to transform from source to JSON object

+ **wsasm_obj2mem(ret)**
+ **wsasm_obj2mem(ret) -> ret**
* Assembler API to transform from JSON object to main memory content (binary)

+ **wsasm_src2mem(datosCU, asm_source, options)**
+ **wsasm_src2mem(datosCU, asm_source, options) -> ret**
* Assembler API to transform from source to main memory content (binary)
* Equivalent to wsasm_prepare_context + wsasm_prepare_source + wsasm_prepare_options + wsasm_src2obj + wsasm_obj2mem

+ **wsasm_src2src(datosCU, text, options)**
+ **wsasm_src2src(datosCU, text, options) -> ret**
* Assembler API to transform from source to source (following options)
* The current available option(s) is/are:
* options.instruction_comma = true -> add ',' between instructions fields (e.g.: li x0 1 -> li x0, 1)
* options.instruction_comma = true => add ',' between instructions fields (e.g.: li x0 1 -> li x0, 1)
* It returns the source code at ret.src_alt


<a name="asmng-todo"/>
Expand Down Expand Up @@ -123,10 +124,11 @@ sequenceDiagram
* Description:
* Load JSON object into main memory
* Auxiliary functions are:
* wsasm_writememory_if_word ( mp, gen, track_source, track_comments )
* wsasm_writememory_and_accumulate ( mp, gen, valuebin )
* wsasm_writememory_and_accumulate_part ( mp, gen, valuebin, track_source, track_comments )
* wsasm_zeropadding_and_writememory ( mp, gen )
* wsasm_writememory_if_word ( mp, gen, track_source, track_comments )
* wsasm_writememory_and_accumulate ( mp, gen, valuebin )
* wsasm_writememory_and_accumulate_part ( mp, gen, valuebin, track_source_j, track_source, track_comments )
* wsasm_writememory_and_accumulate_part_endian ( ret_mp, gen, obj_i, valuebin, n_bytes, j_byte )
* wsasm_zeropadding_and_writememory ( mp, gen )

```mermaid
sequenceDiagram
Expand Down
60 changes: 36 additions & 24 deletions sim_sw/assembly/asm_ng.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function wsasm_new_objElto ( base_elto )
byte_size: 0, // size(datatype) in bytes
value: '0',
format: '',
endian: 'none', // 1 byte: 'none', >1 byte: 'little' | 'big'

binary: '',
firm_reference: null,
Expand All @@ -49,6 +50,7 @@ function wsasm_new_objElto ( base_elto )
elto.seg_name = base_elto.seg_name ;
elto.datatype = base_elto.datatype ;
elto.byte_size = base_elto.byte_size ;
elto.endian = base_elto.endian ;
}

return elto ;
Expand Down Expand Up @@ -616,6 +618,9 @@ function wsasm_src2obj_data ( context, ret )

// Get value size in bytes
elto.byte_size = wsasm_get_datatype_size(elto.datatype) ;
if (elto.byte_size > 1) {
elto.endian = context.endian ;
}

// <value> | .<directive>
asm_nextToken(context) ;
Expand Down Expand Up @@ -1391,6 +1396,7 @@ function wsasm_src2obj_text ( context, ret )

elto = wsasm_new_objElto(null) ;
elto.seg_name = seg_name ;
elto.endian = context.endian ;

//
// .text | .text
Expand Down Expand Up @@ -1988,8 +1994,7 @@ function wsasm_obj2src ( context, ret, options )
// * wsasm_writememory_and_accumulate ( mp, gen, valuebin )
// * wsasm_zeropadding_and_writememory ( mp, gen )
// * wsasm_writememory_and_accumulate_part ( mp, gen, valuebin, track_source_j, track_source, track_comments )
// * wsasm_writememory_and_accumulate_part_for_big_endian ( ret_mp, gen, obj_i, valuebin, n_bytes, j_byte )
// * wsasm_writememory_and_accumulate_part_for_little_endian ( ret_mp, gen, obj_i, valuebin, n_bytes, j_byte )
// * wsasm_writememory_and_accumulate_part_endian ( ret_mp, gen, obj_i, valuebin, n_bytes, j_byte )
//

function wsasm_writememory_if_word ( mp, gen, track_source, track_comments )
Expand Down Expand Up @@ -2058,30 +2063,36 @@ function wsasm_writememory_and_accumulate_part ( mp, gen, valuebin, track_source
}
}

function wsasm_writememory_and_accumulate_part_for_big_endian ( ret_mp, gen, obj_i, valuebin, n_bytes, j_byte )
{
var b_index = j_byte * BYTE_LENGTH ;
var valuebin8 = valuebin.substr(b_index, BYTE_LENGTH) ;

wsasm_writememory_and_accumulate_part(ret_mp, gen, valuebin8, null, obj_i.track_source, obj_i.comments) ;
}

function wsasm_writememory_and_accumulate_part_for_little_endian ( ret_mp, gen, obj_i, valuebin, n_bytes, j_byte )
function wsasm_writememory_and_accumulate_part_endian ( ret_mp, gen, obj_i, valuebin, n_bytes, j_byte )
{
var b_index = 0 ;
var b_index = 0 ;

switch (obj_i.endian)
{
case 'big': // big endian
b_index = j_byte * BYTE_LENGTH ;
break ;

case 'little': // little endian
if (n_bytes < WORD_BYTES) {
b_index = n_bytes - j_byte - 1 ;
}
else {
b_index = (j_byte / WORD_BYTES) >>> 0 ;
b_index = b_index * WORD_BYTES + WORD_BYTES - (j_byte % WORD_BYTES) - 1 ;
}

if (n_bytes < WORD_BYTES) {
b_index = n_bytes - j_byte - 1 ;
}
else {
b_index = (j_byte / WORD_BYTES) >>> 0 ;
b_index = b_index * WORD_BYTES + WORD_BYTES - (j_byte % WORD_BYTES) - 1 ;
}
b_index = b_index * BYTE_LENGTH ;
break ;

b_index = b_index * BYTE_LENGTH ;
var valuebin8 = valuebin.substr(b_index, BYTE_LENGTH) ;
default: // none
b_index = n_bytes - j_byte - 1 ;
b_index = b_index * BYTE_LENGTH ;
break ;
}

wsasm_writememory_and_accumulate_part(ret_mp, gen, valuebin8, null, obj_i.track_source, obj_i.comments) ;
var valuebin8 = valuebin.substr(b_index, BYTE_LENGTH) ;
wsasm_writememory_and_accumulate_part(ret_mp, gen, valuebin8, null, obj_i.track_source, obj_i.comments) ;
}


Expand Down Expand Up @@ -2113,6 +2124,7 @@ function wsasm_prepare_context ( CU_data, options )
context.stackRegister = null ;
context.version = CU_data.version ;
context.options = {} ; // here
context.endian = 'little' ; // TODO: get from firmware

// Fill the assembler configuration
context.options = wsasm_expand_options(options) ;
Expand Down Expand Up @@ -2298,7 +2310,7 @@ function wsasm_obj2mem ( ret )
gen.is_assembly = true ;

// fill for little-endian by default...
wsasm_writememory_and_accumulate_part_for_little_endian(ret.mp, gen, ret.obj[i], valuebin, n_bytes, j) ;
wsasm_writememory_and_accumulate_part_endian(ret.mp, gen, ret.obj[i], valuebin, n_bytes, j) ;
}
}
else if (wsasm_has_datatype_attr(ret.obj[i].datatype, "numeric"))
Expand All @@ -2312,7 +2324,7 @@ function wsasm_obj2mem ( ret )
for (let j=0; j<n_bytes; j++)
{
// fill for little-endian by default...
wsasm_writememory_and_accumulate_part_for_little_endian(ret.mp, gen, ret.obj[i], valuebin, n_bytes, j) ;
wsasm_writememory_and_accumulate_part_endian(ret.mp, gen, ret.obj[i], valuebin, n_bytes, j) ;
}
}
else if (wsasm_has_datatype_attr(ret.obj[i].datatype, "string"))
Expand Down
2 changes: 1 addition & 1 deletion ws_dist/min.sim_all.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ws_dist/min.wepsim_node.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ws_dist/min.wepsim_web.js

Large diffs are not rendered by default.

11 changes: 0 additions & 11 deletions ws_dist/repo/examples_set/rv32/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -1021,16 +1021,5 @@
"assembly": "s6e1",
"description": "<span data-langkey='example_06_01'>Test example.</span>",
"testing": true
},
{
"id": "R5E2",
"title": "IEEE 754 (32 bits)",
"type": "<span data-langkey='Special'>Special</span>",
"modes": "newbie,intro,rv",
"hardware": "rv",
"microcode": "rv_base",
"assembly": "s6e7",
"description": "<span data-langkey='example_01_01'>Simple example with fetch, arithmetic instructions, and basic .text segment.</span>",
"testing": true
}
]
11 changes: 0 additions & 11 deletions ws_dist/repo/examples_set/rv32/es_rv.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,5 @@
"assembly": "s6e1",
"description": "<span data-langkey='example_06_01'>Test example.</span>",
"testing": true
},
{
"id": "R5E2",
"title": "IEEE 754 (32 bits)",
"type": "<span data-langkey='Special'>Special</span>",
"modes": "newbie,intro,rv",
"hardware": "rv",
"microcode": "rv_base",
"assembly": "s6e7",
"description": "<span data-langkey='example_01_01'>Simple example with fetch, arithmetic instructions, and basic .text segment.</span>",
"testing": true
}
]
3 changes: 2 additions & 1 deletion ws_dist/repo/microcode/rv32/rv_min.mc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# WepSIM (https://wepsim.github.io/wepsim/)
#

firmware_version=2,
begin
{
fetch: # IR <- MP[PC]
Expand All @@ -14,7 +15,7 @@ begin
}

test {
co=010110,
oc(6:0)=0010110,
nwords=1,
{
(),
Expand Down

0 comments on commit 8680cfe

Please sign in to comment.