NIOS V/g version 1.0 vs 2.0 Atomic instruction
Using NIOS/g 1.0 the following code works:
00001604: lw a5,-20(s0)
00001608: lw a4,-24(s0)
0000160c: fence iorw,ow
00001610: amoswap.w.aq zero,a4,(a5)
Using NIOS/g 2.0 an exception occurs when 1610 executes, amoswap. The mcause register value is 2, stating it is an illegal instruction.
Recompile the code, did not fix issue. Validated the memory location is accessible.
According to the web site, A (atomic instructions should be supported). The API C/C++ API is std::atomic<uint32_t> value being updated.
_GLIBCXX_ALWAYS_INLINE void
store(__int_type __i, memory_order __m = memory_order_seq_cst) noexcept
{
memory_order __b __attribute__ ((__unused__))
= __m & __memory_order_mask;
__glibcxx_assert(__b != memory_order_acquire);
__glibcxx_assert(__b != memory_order_acq_rel);
__glibcxx_assert(__b != memory_order_consume);
__atomic_store_n(&_M_i, __i, int(__m)); <--- the function calling the fence/swap
From https://www.intel.com/content/www/us/en/docs/programmable/683632/23-4/processor-73511.html the processor should support Atomic instructions. Version 1.0 did.
Tim